import React, { useRef } from "react";
import PubSub from 'pubsub-js';

export default function B() {
  let input = useRef();
  return (
    <div>
      <div>B</div>
      <input type="text" ref={input}  /><button onClick={() => {
        //发布消息
        PubSub.publish('text', input.current.value);
      }}>发送</button>
    </div>
  );
}
